﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Engine.Objects;
namespace Engine.Components
{
   public class CameraManager :BaseManager
    {
        private Dictionary<string, ICamera> _cameras = new Dictionary<string, ICamera>(0);
        private ICamera _maincamera;
        public CameraManager(NOWAEngine _game, ComponentManager manager, bool nodel = false)
            : base(_game, manager, nodel)
        {        
            //create main camera
            DEFAULTCamera cam=new DEFAULTCamera(_game,true);
            cam.LookAt(new Vector3(0.5f, 0.5f, -3), new Vector3(0.5f,0.5f,0), Vector3.Up);
            
            _maincamera = cam;
            
            _cameras.Add("MainCamera",_maincamera);
            // TODO: Complete member initialization            
        }
        public ICamera getCameraByName(string name)
        {
            return _cameras[name];
        }
        public void AddCamera(ICamera cam)
        {
            _cameras.Add(cam.Name,cam);
        }
        public ICamera GetMaincamera()
        {
            return _maincamera;
        }
        public override void Initialize()
        {
            foreach (var item in _cameras)
            {
                item.Value.Initialize();
            }
          
            base.Initialize();
        }
        public override void Update(GameTime gameTime)
        {
           foreach (var item in _cameras)
            {
                item.Value.Update(gameTime);
            }
           
            base.Update(gameTime);
        }
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);
        }
        protected override void LoadContent()
        {
            base.LoadContent();
        }

        


        
    }
}
